# sudo 必须输入密码的问题

#修订 sudo files.
1.sudo visudo
# insert one line.
user_abc    ALL=(ALL:ALL) ALL

2.create polkit rules:
#for mosquitto.service.
sudo nano /etc/polkit-1/rules.d/10-mosquitto-restart.rules
#the content of that files:
   polkit.addRule(function(action, subject) {
     if (action.id == "org.freedesktop.systemd1.manage-units" && 
         action.lookup("unit") == "mosquitto.service") {
       return polkit.Result.YES;
     }
   });
#for another service:
kde@pc:~/kde_monitor/shake$ sudo cp /etc/polkit-1/rules.d/10-mosquitto-restart.rules /etc/polkit-1/rules.d/10-redis-server-restart.rules
kde@pc:~/kde_monitor/shake$ sudo nano /etc/polkit-1/rules.d/10-redis-server-restart.rules
#need not reboot, just restart polkit, can make it works.
kde@pc:~/kde_monitor/shake$ sudo systemctl restart polkit



#LD_LIBRARY_PATH
vi ~/.bashrc
export LD_LIBRARY_PATH=/home/user_abc/app:$LD_LIBRARY_PATH


#创建服务
sudo nano /etc/systemd/system/my_service.service

#内容
[Unit]
Description=kde shm vibration daemon service
After=sub.service                                                                           /etc/systemd/system/shm_vibration.service *                                                                                         
requires=sub.service

[Service]
ExecStart=sudo -E /home/user_abc/main_app
Restart=always
RestartSec=30
User=root

[Install]
WantedBy=multi-user.target




